/**
*      author: Y_Yao
*      created: 2024-09-27 15:49:32
**/

#include<bits/stdc++.h>

using namespace std;
using LL = long long;
const int INF = 0x3f3f3f3f;
const int N = 1e8 + 3;
vector<LL> primes;
bool vis[N];
int cnt = 0;

void get_primes(int n)
{
    for(int i = 2;i <= n;i++)
    {
        if(!vis[i]) primes.push_back(i);
        for(auto e : primes)
        {
            if(e * i > n) break;
            vis[i * e] = true;
            if(i % e == 0) break;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,q;
    cin >> n >> q;
    get_primes(n);
    int k;
    while(q--)
    {
        cin >> k;
        cout << primes[k-1] << endl;
    }
    return 0;
}